package cn.zzf.service.impl;

import cn.zzf.bean.UserLog;
import cn.zzf.mapper.UserLogMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author GaoFeng2017
 * @date 2018-06-28 15:54:39
 **/

@Service
public class UserLogServiceImpl implements cn.zzf.service.UserLogService {

    private static Logger logger = LoggerFactory.getLogger(UserLogServiceImpl.class);

    @Autowired
    private UserLogMapper userLogMapper;

    @Override
    @Transactional(rollbackFor = RuntimeException.class,propagation = Propagation.REQUIRED)
    public void add(UserLog userLog) {

        try {
            logger.debug("入参,{}",userLog.toString());
            Integer count = userLogMapper.insertUserLog(userLog);

            if (count <= 0) {
                logger.info("插入失败,{}",userLog.toString());
                return;
            }
            logger.info("插入成功,{}",userLog.toString());
        } catch (Exception e) {
            logger.error("插入异常,{},异常信息：{}",userLog.toString(),e);
        }

        throw new RuntimeException();
    }
}
